//js 调用
$(function(){
   //弹窗
   // $('#myModal').modal();
   //构造web3对象
   var web3 = new Web3(new Web3.providers.HttpProvider("http://127.0.0.1:8545"));
   web3.eth.getAccounts(function(e,r){
      console.log(e,r);
   });
   //构造hotelSys合约对象
   var hotelSysContractAddr = "0x514e3eeb511639e1f2ccdbf70f830216807db2f6";
   var hotelSysObj = new web3.eth.Contract(hotelsysABI, hotelSysContractAddr);
   var ownerAddr = "0x5a61e77544bb569cf7e5d2739a03db1e21b49aff"
   console.log(hotelSysObj)





   var age = 26
   var is_crim = false


   //调用checkPersonIn4
   $(".check").on("click",function(){
      hotelSysObj.methods.checkPersonIn4(age,is_crim).send({
         from : ownerAddr,        //owner
         gas  : 300000
      },function(error,result){
         if(!error){
            alert("允许入住！年龄:"+age+"; 是否有前科:"+is_crim);
         }else{
            alert("拒绝入住！年龄:"+age+"; 是否有前科:"+is_crim);
            console.log("拒绝入住:",error);
         }
      });
   });
   

});